/********************************************************************************
  * @file     SD93F115B_it.c 
  * @author   TEST TEAM ONE（FM)													    	
  * @version  v0															    	
  * @date     March 2020												    	
  * @brief    Main Interrupt Service Routines.
  *           This file provides template for all exceptions handler and 
  *           peripherals interrupt service routine.
  *           
  * Copyright (C) 2020  Hangzhou SDIC Microelectronics Co., Ltd
*********************************************************************************/

/* Includes */
#include "SD93F115B_it.h"
#include "define.h"
#include "time.h"
#include "uart.h"

#define IsRTC1minMode 1
/******************************************************************************
 *  SD931X Peripherals Interrupt Handlers                  	  
 *  Add here the Interrupt Handler for the used peripheral(s) , for the  
 *  available peripheral interrupt handler's name please refer to the startup 
 *  file (Startup_SD931X.s).                                                    
******************************************************************************/

/*------------------------------------------------------------
  * @brief  This function handles SysTick interrupt request.
  * @param  None
  * @retval None
  -------------------------------------------------------------*/
void SysTick_IRQHandler(void) 
{
	
}
/*------------------------------------------------------------
  * @brief  This function handles LVD interrupt request.
  * @param  None
  * @retval None
  -------------------------------------------------------------*/
void LBT_IRQHandler(void)
{
	
}
/*------------------------------------------------------------
  * @brief  This function handles XT0Fault interrupt request.
  * @param  None
  * @retval None
  -------------------------------------------------------------*/
void XT0Fault_IRQHandler(void)
{
	
}
/*------------------------------------------------------------
  * @brief  This function handles XT1Fault interrupt request.
  * @param  None
  * @retval None
  -------------------------------------------------------------*/
void XT1Fault_IRQHandler(void)
{
	
}
/*------------------------------------------------------------
  * @brief  This function handles FLASH interrupt request.
  * @param  None
  * @retval None
  -------------------------------------------------------------*/
void FLASH_IRQHandler(void)
{
	
}
/*------------------------------------------------------------
  * @brief  This function handles EXTI0 interrupt request.
  * @param  None
  * @retval None
  -------------------------------------------------------------*/
void EXTI0_IRQHandler(void)
{
	EXINT_ClearEXITStatus(EXINT_INT0);
	PWR_ACMLevelConfig(PWR_ACMLevel_VNTAT); 
	/*
	if(GPIO_ReadOutputDataBit(GPIO4,GPIO_Pin_0))
		P40_0;
	else
		P40_1;
		*/
}
/*------------------------------------------------------------
  * @brief  This function handles EXTI1 interrupt request.
  * @param  None
  * @retval None
  -------------------------------------------------------------*/
void EXTI1_IRQHandler(void)
{
	EXINT_ClearEXITStatus(EXINT_INT1);
	/*if(GPIO_ReadOutputDataBit(GPIO4,GPIO_Pin_1))
		GPIO_WriteOutputDataBit(GPIO4, GPIO_Pin_1,0);
	else
		GPIO_WriteOutputDataBit(GPIO4, GPIO_Pin_1,1);*/
}
/*------------------------------------------------------------
  * @brief  This function handles KEY interrupt request.
  * @param  None
  * @retval None
  -------------------------------------------------------------*/
void KEY_IRQHandler(void)
{
	//EXINT_ClearEXITStatus(EXINT_KEY);
	EXINT_ClearEXITStatus(EXINT_KEY0);
	EXINT_ClearEXITStatus(EXINT_KEY1);
	EXINT_ClearEXITStatus(EXINT_KEY2);
	EXINT_ClearEXITStatus(EXINT_KEY3);
	EXINT_ClearEXITStatus(EXINT_KEY4);
	EXINT_ClearEXITStatus(EXINT_KEY5);
	EXINT_ClearEXITStatus(EXINT_KEY6);
}
/*------------------------------------------------------------
  * @brief  This function handles UART0 interrupt request.
  * @param  None
  * @retval None
  ------------------------------------------------------------*/
void UART0_IRQHandler(void)
{	
 //   UART_ClearFlagStatus(UART0, UART_Flag_RXNE);
//	if(UART_GetFlagStatus(UART0,UART_Flag_TXE));
		//UART_SendData(UART0,UART_ReceiveData(UART0));
		Uart0_Rev_Interrupt();
}

/*------------------------------------------------------------
  * @brief  This function handles UART1 interrupt request.
  * @param  None
  * @retval None
  ------------------------------------------------------------*/
void UART1_IRQHandler(void)
{	
	/*uint8_t tmp;
	tmp=UART_ReceiveData(UART0);
	UART_SendData(UART0,tmp);
    */	
}
/*------------------------------------------------------------
  * @brief  This function handles I2C interrupt request.
  * @param  None
  * @retval None
  ------------------------------------------------------------*/
void I2C_IRQHandler(void)
{
	/*if(I2C_GetITStatus(I2C_IT_ADDRIE)==SET)
	{
		
	}*/
}
/*------------------------------------------------------------
  * @brief  This function handles SPI interrupt request.
  * @param  None
  * @retval None
  ------------------------------------------------------------*/
void SPI_IRQHandler(void)
{

	/*if(SPI_GetITStatus(SPI_IT_TXE)==SET)
	{
		
	}*/
}
/*------------------------------------------------------------
  * @brief  This function handles TM0 interrupt request.
  * @param  None
  * @retval None
  ------------------------------------------------------------*/
void TM0_IRQHandler(void)
{
	TM_ClearITStatus(TM0);
	//GPIO7->ODR = (GPIO7->ODR^0x01);	//test P70
	Timer0_int();
}
/*------------------------------------------------------------
  * @brief  This function handles TM1 interrupt request.
  * @param  None
  * @retval None
  ------------------------------------------------------------*/
void TM1_IRQHandler(void)
{
	
}
/*------------------------------------------------------------
  * @brief  This function handles TM2 interrupt request.
  * @param  None
  * @retval None
  ------------------------------------------------------------*/
void TM2_IRQHandler(void)
{
	
}
/*------------------------------------------------------------
  * @brief  This function handles SARADC interrupt request.
  * @param  None
  * @retval None
  ------------------------------------------------------------*/
void SARADC_IRQHandler(void)
{
	if(SARADC_GetITStatus(SARADC_SAMPIE)==SET)
	{
		//SARtmp=SARADC_ChangeData();						//SARADC转换码值		
	}
}
/*------------------------------------------------------------
  * @brief  This function handles SDADC interrupt request.
  * @param  None
  * @retval None
  ------------------------------------------------------------*/
void SDADC_IRQHandler(void)
{
	/*SDADC_ClearITStatus();
	adcconvertcount++;
	if(adcconvertcount>5)
	{
		SDADCDataBUF[0]=SDADC_GetConversionValue();
		SDADC_ITCmd(DISABLE);
		adcconvertcount=0;
		stateFlag.adcupdata=1;
	}*/
}
/*------------------------------------------------------------
  * @brief  This function handles IWDG interrupt request.
  * @param  None
  * @retval None
  ------------------------------------------------------------*/
void IWDG_IRQHandler(void)
{
	
}
/*------------------------------------------------------------
  * @brief  This function handles WWDG interrupt request.
  * @param  None
  * @retval None
  ------------------------------------------------------------*/
void WWDG_IRQHandler(void)
{
	
}

/*------------------------------------------------------------
  * @brief  This function handles RTC interrupt request.
  * @param  None
  * @retval None
  ------------------------------------------------------------*/
void RTC_IRQHandler(void)
{
	if(!IsRTC1minMode&&RTC_GetITStatus(RTC_IT_RTCIE))
	{
		RTC_ClearITStatus(RTC_IT_RTCIE);                       //清半秒中断标志位
		//GPIO7->ODR = (GPIO7->ODR^0x02);	//test P71
		Rtc_int(); 
		/*
		if(GPIO_ReadOutputDataBit(GPIO4,GPIO_Pin_2))
			GPIO_WriteOutputDataBit(GPIO4, GPIO_Pin_2,0);      //I/O反转
		else
			GPIO_WriteOutputDataBit(GPIO4, GPIO_Pin_2,1);
		*/
	}
	
    if(IsRTC1minMode&&RTC_GetITStatus(RTC_IT_TAIE))
	{
		RTC_ClearITStatus(RTC_IT_TAIE); 
		Rtc_1min_interrupt();
		/*
		RTC_ClearITStatus(RTC_IT_TAIE);                       //清半秒中断标志位
		GPIO_WriteOutputDataBit(GPIO4, GPIO_Pin_3,1);         //p43=1
		/*/
	}
	/*
	if(GPIO_ReadOutputDataBit(GPIO4,GPIO_Pin_4))
		GPIO_WriteOutputDataBit(GPIO4, GPIO_Pin_4,0);      //I/O反转
	else
		GPIO_WriteOutputDataBit(GPIO4, GPIO_Pin_4,1);
	*/
}		

/*------------------------------------------------------------
  * @brief  This function handles PWM0 interrupt request.
  * @param  None
  * @retval None
  ------------------------------------------------------------*/
void PWM0_IRQHandler(void)
{
	PWM_ClearITStatus(PWM0);
}
/*------------------------------------------------------------
  * @brief  This function handles PWM1 interrupt request.
  * @param  None
  * @retval None
  ------------------------------------------------------------*/
void PWM1_IRQHandler(void) 
{
	PWM_ClearITStatus(PWM1);
}


/****************************END OF FILE****************************/











